import React, { useContext } from "react"

import { AppContext } from "../App"

export default function D() {
  const {user, update} = useContext<Partial<ContextProps>>(AppContext)

  const upd=()=>{
    update && update({name:"star war", age:10})
  }

  return (
    <div className="D">
      <p>D组件,接收到数据:<br/>
        <span>{user?.name}-{user?.age}</span>
      </p>
      <p>
        <button onClick={upd}>update</button>
      </p>
    </div>
  )
}
